<template>
	<view class="">
		<indexPage v-if="lodingShow"></indexPage>
		<view class="content">
			<view class="inputs_info">
				<view class="ipt">
					<input @confirm='inputs' confirm-type="search" class="inputs" type="text" v-model="text" placeholder="大家都在搜" />
					<uni-icons type="search" size="24" color="#888888"></uni-icons>
				</view>
			</view>
			<swipergo :swiperid="swiperid1" :upHeight="300" :upWith="716"></swipergo>
			<view class="content1 page_width">
				<view class="img_flex">
					<view class="item_img" v-for="(item,index) in contlist" :key="index" @click="goPage(item)">
						<image :class="index == 1? 'imgs1' :'imgs'" :src="item.path" mode=""></image>
						<view  :class="index == 1? 'text1' :'text'">
							{{item.t}}
						</view>
					</view>
				</view>
				<view class="text_flex">
					<image class="img_l" src="../../static/indeximg/icon.png" mode=""></image>
					<swiper class="swiper" circular :vertical='true' :indicator-dots="false" :autoplay="true"
						interval="3000" duration="1000">
						<swiper-item class="items_sw" v-for="(item,index) in tzList" :key="index" @click="goNoticeInfo(item)">
							<view class="texts">
								{{item.title}}
							</view>
						</swiper-item>
					</swiper>
					<view class="img_r" @click="goNotice()">
						更多
					</view>
				</view>
			</view>
			<swipergo :swiperid="swiperid2" :upHeight="300" :upWith="716"></swipergo>
			<view class="tit">
				<view class="ts">
					<image class="timg" src="../../static/s.png" mode=""></image>
					<view class="">优质商家</view>
					<image class="timg" src="../../static/s.png" mode=""></image>
				</view>
				<view class="cont_flex page_width">
					<view class="flex_item" v-for="(item,index) in businessList" :key="index" @click="gobusiness(item)">
						<image :src="item.typeHead" mode=""></image>
						<view class="text">{{item.typeName}}</view>
					</view>
				</view>
			</view>
			<swipergo :swiperid="swiperid3" :upHeight="300" :upWith="716"></swipergo>
			<view class="tit">
				<view class="ts">
					<image class="timg" src="../../static/s.png" mode=""></image>
					<view class="">最新杂志</view>
					<image class="timg" src="../../static/s.png" mode=""></image>
				</view>
				<view class="cont_flex1 page_width">
					<view class="flex_items" v-for="(item,index) in magazineList" :key="index" @click="gomagazines(item)">
						<image :src="item.image" mode=""></image>
						<view class="text">{{item.name}}</view>
					</view>
				</view>
			</view>
			<view class="pos_ads">
				<view class="items" @click.stop="goPhone">
					<image src="../../static/p.png" mode=""></image>
				</view>
				<view class="items its">
					<button :plain='true' open-type="contact"></button>
					<image src="../../static/k.png" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import indexPage from '../../components/indexPage/indexPage.vue'
	import { getCompanyList,getNotice,getMagazineList,getidInfo} from '@/common/http.api.js';
	export default {
		components: {
			indexPage
		},
		data() {
			return {
				swiperid1:1,
				swiperid2:2,
				swiperid3:3,
				text:'',
				contlist: [{
						id: 1,
						path: require('../../static/indeximg/icon1.png'),
						t: '优质商家'
					},
					{
						id: 2,
						path: require('../../static/indeximg/icon2.png'),
						t: '展会'
					},
					{
						id: 3,
						path: require('../../static/indeximg/icon3.png'),
						t: '电子杂志'
					},
					{
						id: 4,
						path: require('../../static/indeximg/icon4.png'),
						t: '需求发布'
					}
				],
				lodingShow: true,
				businessList:[],
				tzList:[],
				magazineList:[],
				phone:''
			}
		},
		onLoad() {
			this.getlist()
		},
		methods: {
			goPhone(){
				uni.makePhoneCall({
					phoneNumber:this.phone,
					success() {
					}
				});
			},
			gobusiness(item){
				uni.navigateTo({
					url:`/pages/business/businessInfoList?id=${item.id}`
				})
			},
			getlist(){
				getidInfo({id:1}).then(res=>{
					if(res.code == 200){
						this.phone = res.data.phone
					}
				})
				//通知列表
				getNotice({pageSize:5,pageNum: 1}).then(res=>{
					this.tzList = res.rows
					this.$nextTick(() => {
						this.lodingShow = false;
					});
				})
				//商家列表
				getCompanyList({parentId:0,pageSize:6,pageNum: 1}).then(res=>{
					this.businessList = res.rows
				})
				getMagazineList({pageSize:8,pageNum: 1}).then(res=>{
					this.magazineList = res.rows
				})

			},
			inputs(e){
				uni.navigateTo({
					url:`/pages/business/search?textinfo=${e.detail.value}`
				})
				this.text = ''
			},
			goNotice(){
				uni.navigateTo({
					url:'/pages/my/notice'
				})
			},
			goNoticeInfo(item){
				uni.navigateTo({
					url: `/pages/my/noticeinfo?id=${item.id}`
				})
			},
			gomagazines(item){
				uni.navigateTo({
					url:`/pages/index/magazines/magazinesList?id=${item.id}`
				})
			},
			goPage(item){
				console.log(item);
				if(item.id == 1){
					uni.switchTab({
						url:'/pages/business/business'
					})
				}else if(item.id == 2){
					uni.switchTab({
						url:'/pages/exhibition/exhibition'
					})
				}else if(item.id == 3){
					uni.navigateTo({
						url:'/pages/index/magazines/magazines'
					})
				}else{
					uni.navigateTo({
						url:'/pages/index/release'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F0F0F1;
	}


	.content1 {
		margin: 0rpx auto;
		height: 364rpx;
		border-radius: 20rpx;
		background-color: #022B5F;
		width: 716rpx;
		.img_flex {
			display: flex;
			height: 244rpx;
			width: 100%;
			padding: 24rpx;
			justify-content: space-between;
			box-sizing: border-box;
			border-bottom: 1px solid #1A4878;
		}
		.item_img {
			background-color: #fff;
			width: 122rpx;
			height: 122rpx;
			border-radius: 50%;
			text-align: center;
			.imgs {
				width: 64rpx;
				height: 64rpx;
				margin-top: 29rpx;
			}

			.imgs1 {
				width: 48rpx;
				height: 48rpx;
				margin-top: 37rpx;
			}
		}
		.text {
			margin-top: 50rpx;
			color: #fff;
			font-size: 28rpx;
		}
		.text1 {
			margin-top: 58rpx;
			color: #fff;
			font-size: 28rpx;
		}

		.text_flex {
			display: flex;
			width: 100%;
			padding: 34rpx;
			box-sizing: border-box;
			align-items: center;

			.img_l {
				width: 48rpx;
				height: 48rpx;
			}

			.swiper {
				width: 400rpx;
				height: 40rpx;
				flex: 1;
				margin: 0 10rpx;

				.items_sw {
					height: 40rpx;
					color: #fff;

					.texts {
						font-size: 30rpx;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}
			}

			.img_r {
				color: #fff;
				font-size: 30rpx;
			}
		}
	}

	.tit {
		.ts {
			margin: 38rpx auto;
			display: flex;
			align-items: center;
			width: 260rpx;
			color: #022B5F;
			font-size: 40rpx;
		}
		.timg {
			width: 48rpx;
			height: 48rpx;
		}
		.cont_flex {
			display: flex;
			margin: 10rpx auto;
			flex-wrap: wrap;
			justify-content: space-between;
			text-align: center;
			width: 716rpx;
			.flex_item {
				width: 346rpx;
				height: 320rpx;
				background-color: #fff;
				margin-bottom: 28rpx;
				image {
					width: 100%;
					height: 220rpx;
				}
				.text {
					margin: 0 auto;
					width: 300rpx;
					font-size: 32rpx;
					line-height: 80rpx;
					white-space:nowrap;
					overflow:hidden;
				}
			}
		}


		.cont_flex1 {
			display: flex;
			margin: 10rpx auto;
			flex-wrap: wrap;
			justify-content: space-between;
			text-align: center;
			box-sizing: border-box;
			width: 716rpx;
			.flex_items {
				width: 350rpx;
				height: 580rpx;
				background-color: #fff;
				margin-bottom: 28rpx;
				border-radius: 20rpx;
				padding: 22rpx;
				box-sizing: border-box;

				image {
					width: 308rpx;
					height: 472rpx;
				}

				.text {
					width: 308rpx;
					font-size: 32rpx;
					line-height: 60rpx;
					white-space:nowrap;
					overflow:hidden;
				}
			}
		}
	}
	.pos_ads{
		position: fixed;
		right: 24rpx;
		top: 64%;
		.items{
			width: 92rpx;
			height: 92rpx;
			background-color:rgba(242,136,9,0.8);
			margin-bottom: 30rpx;
			border-radius: 46rpx;
			text-align: center;
			display: flex;
			align-items: center;
			justify-content: center;
			image{
				width: 48rpx;
				height: 48rpx;
			}
		}
		.its{
			background-color: rgba(238,82,82,0.8);
			button{
				width: 92rpx;
				height: 92rpx;
				position: absolute;
				border-radius: 46rpx;
				border: none;
			}
		}
		
	}
</style>